<%--
  Created by IntelliJ IDEA.
  User: 22531
  Date: 2021/6/14
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/jquery.edatagrid.js"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#dg').edatagrid({
                url: '/admin/getAllNotice',
                saveUrl: '',
                updateUrl: '',
                destroyUrl: '/admin/AdDelNotice',
                title: '所有通告',
                idField:'id',
                columns: [[
                    {field: 'id', title: 'ID', align: 'center'},
                    {field: 'title', title: '标题', align: 'center'},
                ]],
                singleSelect: true,
                toolbar: [{
                    iconCls: 'icon-reload',
                    text:'刷新',
                    handler: function(){
                        $('#dg').edatagrid('reload');
                    }
                },'-',{
                    iconCls: 'icon-remove',
                    text: '删除公告',
                    handler: function (){
                        $('#dg').edatagrid('destroyRow');
                    },
                }],
                onSuccess:function (index,row){
                    if(row.msg){
                        $.messager.alert('操作结果','操作成功!','info');
                        $('#dg').edatagrid('reload');
                    }
                    else {
                        $.messager.alert('操作结果','操作失败!'+row.error,'warning');
                        $('#dg').edatagrid('reload');
                    }
                },
                onError:function (index,row){
                    $.messager.alert('操作结果','服务器错误!','warning');
                    $('#dg').edatagrid('reload');
                },
                onDestroy:function (index,row){
                    if(row.msg){
                        $.messager.alert('操作结果','操作成功!','info');
                        $('#dg').edatagrid('reload');
                    }
                    else {
                        $.messager.alert('操作结果','操作失败!'+row.error,'warning');
                        $('#dg').edatagrid('reload');
                    }
                },
            });
        })
    </script>
</head>
<body>

<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="dg"></table>
</div>
</body>
</html>
